import request from '@/utils/request'

/**
 * 查询用户信息
 * @param {*} params 
 * @returns 
 */
export function listUsers(params) {
    return request({
        url: '/admin/user/list',
        method: 'post',
        data: {
            pageNum: params.pageNum,
            limit: params.limit,
            nickname:params.nickname,
            date:params.date,
            status:params.status
        }
    })
}
/**
 * 删除用户
 */
export function deleteUserById(userId) {
    return request({
        url: '/admin/user/delete',
        method: 'delete',
        params: { userId: userId }
    })
}
/**
 * 新增用户
 * @param {*} user 
 * @returns 
 */
export function saveUser(user) {
    return request({
        url: '/admin/user/save',
        method: 'post',
        data: {
            nickname: user.nickname,
            username: user.username,
            type: user.type,
            status: user.status,
            avatar: user.avatar
        }
    })
}
/**
 * 根据用户id查询用户信息
 * @param {} userId 
 * @returns 
 */
export function getUser(userId) {
    return request({
        url: '/admin/user/' + userId,
        method: 'get'
    })
}
/**
 * 更新用户信息
 * @param {*} user 
 * @returns 
 */
export function updateUser(user) {
    return request({
        url: '/admin/user/',
        method: 'put',
        data: {
            nickname: user.nickname,
            password: user.password,
            type: user.type,
            status: user.status,
            avatar: user.avatar,
            username: user.username,
            userId: user.userId
        }
    })
}